<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style type="text/css">
	body{overflow:auto;}
  thead tr {background-color: ActiveCaption; color: CaptionText;}
  th, td {vertical-align: top; font-family: "宋体", Arial, Helvetica, sans-serif; font-size: 9pt; padding: 3px; }
  table, td {border: 1px solid silver;}
  table {border-collapse: collapse;}
  thead .col0 {width: 20%;}
  thead .col1 {width: 75%;}
	td.col0{font-size:18px;font-weight:bold;color:#f00;}
</style>
    
<body class="white-bg">
    <table>
      <thead>
        <tr>
          <th class="col0">章节</th>
          <th class="col1">内容</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td class="col0">第2章 新闻发布系统设计</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; line-height: 28px;"><span style="font-size:18px;">在开发&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif;">JavaEE&nbsp;</span>的&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif;">Web&nbsp;</span>应用系统时，首先要弄清楚用户的需求，简而言之，要系统做什么， 必须了解和分析客户的需求，尽量准确地掌握客户需要一个什么样的软件系统。</span></p><p class="s5" style="margin: 0pt; padding: 1pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; line-height: 28px; text-align: justify;"><span style="font-size:18px;">在与客户充分地沟通协调后，得到一个双方都认可的需求分析报告，在此基础上，需要 弄清楚怎么做，也就是如何设计并实现客户需要的软件系统。根据软件工程的概念，设计包括 概要设计、详细设计，本书的重点是&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif;">JavaEE&nbsp;</span>框架技术的应用，所以只对新闻发布系统做了比 较简单的设计，包括功能模块设计和数据库设计。</span></p> </td>
        </tr>
        <tr>
          <td class="col0">2.1 系统需求分析</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; line-height: 28px; text-align: justify;"><span style="font-size:18px;">本书以新闻发布系统（已经简化了新闻分类、图片新闻、置顶等功能）作为实战项目， 让读者能够在较短的时间内用一种框架技术（<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="">Nutz</span>、<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="">SSH</span>、<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="">SSM&nbsp;</span>或&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="">JFinal</span>）实现系统的开发。</span></p><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 26pt; font-family: 宋体; line-height: 28px;"><span style="font-size:18px;">有两种用户，普通用户和管理员，不同用户有不同的功能权限。</span></p><p class="s11" style="margin: 0pt; padding: 1pt 0px 0px 47pt; text-indent: -21pt; font-family: Wingdings; line-height: 28px;"><span style="font-size:18px;">?&nbsp;<span class="s5" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: 宋体;">普通用户可以通过系统首页查看分页新闻列表，单击一条新闻后可以在新闻阅读页查 看新闻详情。</span></span></p><p class="s11" style="margin: 0pt; padding: 0px 0px 0px 47pt; text-indent: -21pt; font-family: Wingdings; line-height: 28px;"><span style="font-size:18px;">?&nbsp;<span class="s5" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: 宋体;">管理员除了拥有普通用户的权限以外，还可以通过首页登录到后台管理页。在后台， 可以发布新的新闻，可以查询新闻，修改指定的新闻，删除指定的新闻。</span></span></p><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 26pt; font-family: 宋体;"><span style="font-size:18px;">根据上述系统需求分析，设计系统功能模块如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="">2-1&nbsp;</span>所示。</span></p><p style="margin: 0pt; padding: 0px; font-family: " times="" new="" roman="" serif=""><span style="font-size:18px;"><br style="margin: 0px; padding: 0px;" /></span></p><p style="margin: 0pt; padding: 0px;  text-align:center"><span style="margin: 0px; padding: 0px;"><span style="font-size:18px;"><img th:src="@{/assets/javaeeimg/Image_008.png}" style="margin: 0px; padding: 0px;" alt="" /></span></span><p class="s9" style="margin: 0pt; padding: 2pt 0px 0px 5pt; font-family: 宋体; text-align: center;"><span style="font-size:18px;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: " times="" new="" roman="" serif="">2-1&nbsp;</span>新闻发布系统功能模块</span><br /></p>  
		  </td>
        </tr>
        <tr>
          <td class="col0">2.2 系统功能预览</td>
          <td class="col1"><span style="font-family: 宋体; text-indent: 28px;"><span style="font-size:18px;">不同的用户通过系统进行不同的操作，每一操作都是一个功能的体现，下面给出系统需 要实现的具体功能。</span></span><br /> </td>
        </tr>
        <tr>
          <td class="col0">2.2.1 查看新闻列表</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 26pt; font-family: 宋体; font-size: 18px;">普通用户和管理员都可以查看新闻列表。新闻列表以分页形式展示，每页显示&nbsp;<span class="s6" style="margin: 0px; padding: 0px; font-family: Times New Roman, serif; font-size: 18px;">10&nbsp;</span>条新闻，<span style="font-size: 18px; text-align: center;">每&nbsp;</span><span class="s6" style="font-size: 18px; text-align: center; margin: 0px; padding: 0px; font-family: Times New Roman, serif;">5&nbsp;</span><span style="font-size: 18px; text-align: center;">条新闻后，显示一条分隔线，列表只显示新闻的标题、新闻发布日期，如图&nbsp;</span><span class="s6" style="font-size: 18px; text-align: center; margin: 0px; padding: 0px; font-family: Times New Roman, serif;">2-2&nbsp;</span><span style="font-size: 18px; text-align: center;">所示。</span></p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 38pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_009.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 4pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-2&nbsp;</span>新闻发布系统—新闻列表</p> </td>
        </tr>
        <tr>
          <td class="col0">2.2.2 阅读新闻</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 15.82px;">单击新闻列表中任意一条新闻的标题，系统打开新闻阅读页面，页面显示新闻的标题、 发布者、发布日期、阅读量、新闻内容，如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">2-3&nbsp;</span>所示。</p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 39pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_010.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 4pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-3&nbsp;</span>新闻发布系统—阅读新闻</p> </td>
        </tr>
        <tr>
          <td class="col0">2.2.3 用户登录</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 15.82px; text-align: justify;">如果用户需要发布、修改或者删除新闻，则要以管理员身份登录。登录时输入用户名和 密码，然后单击“登录”按钮或直接回车，如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">2-4&nbsp;</span>所示。</p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 122pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_011.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 4pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-4&nbsp;</span>新闻发布系统—用户登录</p><div><br /></div> </td>
        </tr>
        <tr>
          <td class="col0">2.2.4 发布新闻</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px; text-align: justify;">后台管理界面以边框布局形式展示，顶部区域显示系统&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">logo</span>、登录用户名；左部区域显 示系统菜单；中心区域显示新闻发布区；底部区域显示版权信息。</p><p class="s5" style="margin: 0pt; padding: 1pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 15.82px; text-align: justify;">发布新闻前，输入新闻标题、新闻发布者、新闻内容。新闻内容可以包含文字、图片、 音频、视频、超链接等多种形式，可以设置字的大小、对齐方式、字的颜色、字型等。完成输 入后，单击“保存”按钮，实现发布新闻功能，如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">2-5&nbsp;</span>所示。</p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 25pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_012.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 4pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-5&nbsp;</span>新闻发布系统—发布新闻</p> </td>
        </tr>
        <tr>
          <td class="col0">2.2.5 修改新闻</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px;">在新闻列表中选择待修改的新闻，修改新闻页面上将显示待修改新闻的标题、发布者、 内容；不显示的项（如发布日期、阅读量等），不允许修改。完成修改后，单击“保存”按钮， 实现修改新闻的功能，如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">2-6&nbsp;</span>所示。</p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 20pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_013.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 4pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-6&nbsp;</span>新闻发布系统—修改新闻</p> </td>
        </tr>
        <tr>
          <td class="col0">2.2.6 删除新闻</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 9pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px;">只能删除指定&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">ID&nbsp;</span>的新闻。为了防止误操作删除，在正式删除前，系统会弹出一对话框让 用户确认，仅当用户单击“确定”按钮后，才能删除一条新闻，如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: Times New Roman, serif; font-size: 18px;">2-7&nbsp;</span>所示。</p><p style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px 0px 0px 66pt; font-family: Times New Roman, serif; font-size: 9pt; line-height: 10pt; text-align: center;"><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_014.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 3pt 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;">图&nbsp;<span class="p" style="margin: 0pt; padding: 0px; font-family: Times New Roman, serif; font-size: 9pt;">2-7&nbsp;</span>新闻发布系统—删除新闻</p> </td>
        </tr>
        <tr>
          <td class="col0">2.3 数据库设计</td>
          <td class="col1"><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 26pt; font-family: 宋体; font-size: 18px;">新闻发布系统应包含用户、新闻、系统菜单信息，该系统的实体联系（<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">E-R</span>）图如图&nbsp;<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">2-8</span><span style="font-size: 18px;">所示。</span></p><p style="margin: 0pt; padding: 0px; font-family: times new roman serif; font-size: 9pt"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px; font-family: times new roman serif; font-size: 9pt"><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 0pt; padding: 0px; font-family: times new roman serif; font-size: 9pt" text-align:="" center=""><span style="margin: 0px; padding: 0px;"><img th:src="@{/assets/javaeeimg/Image_015.png}" style="margin: 0px; padding: 0px;" alt="" /></span></p><p class="s9" style="margin: 0pt; padding: 0px 0px 0px 5pt; font-family: 宋体; font-size: 9pt; text-align: center;"><span style="font-size: 9pt;">图&nbsp;</span><span class="p" style="font-size: 9pt; margin: 0pt; padding: 0px; font-family: " times="" new="" roman="" serif="">2-8&nbsp;</span><span style="font-size: 9pt;">新闻发布系统的&nbsp;</span><span class="p" style="font-size: 9pt; margin: 0pt; padding: 0px; font-family: " times="" new="" roman="" serif="">E-R&nbsp;</span><span style="font-size: 9pt;">图</span><br /></p><p class="s5" style="margin: 0pt; padding: 7pt 0px 0px 26pt; font-family: 宋体; font-size: 18px;">（<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">1</span>）用户：代表系统的用户实体，主要包括用户的用户名、姓名、密码和角色。</p><p class="s5" style="margin: 0pt; padding: 1pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px; text-align: justify;">（<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">2</span>）新闻：代表新闻信息，包括新闻的&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">ID</span>、新闻标题、新闻内容、发布时间、发布者（人 或机构）、阅读量（单击量）。</p><p class="s5" style="margin: 0pt; padding: 1pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px; text-align: justify;">（<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">3</span>）系统菜单：代表后台管理页面的菜单项，包括菜单栏目&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">ID</span>、父级&nbsp;<span class="s6" style="margin: 0px; padding: 0px; text-indent: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">ID</span>、菜单栏目名 称、菜单的链接、菜单的权限用户。</p><p class="s5" style="margin: 0pt; padding: 1pt 0px 0px 5pt; text-indent: 21pt; font-family: 宋体; font-size: 18px; line-height: 28px; text-align: justify;">用户与新闻之间的关系有两种，普通用户与新闻之间是多对多的关系，一个用户可以查 看或阅读多条新闻，一条新闻可以被多个用户查看或阅读；管理员用户与新闻之间是一对多的 关系，一个管理员可以管理（增删改查）多条新闻，一条新闻只被一个管理员管理。</p><p class="s5" style="margin: 0pt; padding: 0px 0px 0px 26pt; font-family: 宋体; font-size: 18px; line-height: 28px;">新闻发布系统需要&nbsp;<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">3&nbsp;</span>张表，分别为用户表、新闻表和系统菜单表。 登录系统后台，需要用户信息表，表结构见表&nbsp;<span class="s6" style="margin: 0px; padding: 0px; font-family: " times="" new="" roman="" serif="" font-size:="" 18px="">2-1</span>。</p><p class="s14" style="margin: 0pt; padding: 8pt 0px 0px 47pt; font-family: 黑体, monospace; font-size: 9pt; text-align: center;">表&nbsp;<span class="s15" style="margin: 0px; padding: 0px; font-family: Arial, sans-serif; font-size: 9pt;">2-1&nbsp;</span>用户表（<span class="s15" style="margin: 0px; padding: 0px; font-family: Arial, sans-serif; font-size: 9pt;">user</span>）</p><p style="margin: 0pt; padding: 0px; font-family: times new roman serif; font-size: 9pt"><br style="margin: 0px; padding: 0px;" /></p><div style="margin:0 auto;width: 500px;"><div><table border="1" cellspacing="0" cellpadding="0" width="492"> <tbody><tr><td style="width:76.55pt;"><p><strong>Field</strong></p></td><td style="width:86.95pt;"><p><strong>Type</strong></p></td><td style="width:32.05pt;"><p><strong>Null</strong></p></td><td style="width:26.3pt;"><p><strong>Key</strong></p></td><td style="width:81.05pt;"><p><strong>Default</strong></p></td><td style="width:66.3pt;"><p><strong>Comment</strong></p></td></tr><tr><td style="width:76.55pt;"><p>uid</p></td><td style="width:86.95pt;"><p>varchar(11)</p></td><td style="width:32.05pt;"><p>NO</p></td><td style="width:26.3pt;"><p>PRI</p></td><td style="width:81.05pt;"><p>&nbsp;</p></td><td style="width:66.3pt;"><p><span style="font-family:宋体;">用户名</span></p></td></tr><tr><td style="width:76.55pt;"><p>xm</p></td><td style="width:86.95pt;"><p>varchar(20)</p></td><td style="width:32.05pt;"><p>NO</p></td><td style="width:26.3pt;"><p>&nbsp;</p></td><td style="width:81.05pt;"><p>&nbsp;</p></td><td style="width:66.3pt;"><p><span style="font-family:宋体;">姓名</span></p></td></tr><tr><td style="width:76.55pt;"><p>pwd</p></td><td style="width:86.95pt;"><p>varchar(50)</p></td><td style="width:32.05pt;"><p>NO</p></td><td style="width:26.3pt;"><p>&nbsp;</p></td><td style="width:81.05pt;"><p>&nbsp;</p></td><td style="width:66.3pt;"><p><span style="font-family:宋体;">密码</span></p></td></tr><tr><td style="width:76.55pt;"><p>role</p></td><td style="width:86.95pt;"><p>char(1)</p></td><td style="width:32.05pt;"><p>NO</p></td><td style="width:26.3pt;"><p>&nbsp;</p></td><td style="width:81.05pt;"><p>&nbsp;</p></td><td style="width:66.3pt;"><p><span style="font-family:宋体;">角色</span>1<span style="font-family:宋体;">管理员</span></p></td></tr></tbody></table></div><p><span style="font-family:宋体;">创建</span>user<span style="font-family:宋体;">表的</span>SQL<span style="font-family:宋体;">代码如下：</span></p><p><strong><span style="color:blue;">CREATE&nbsp;</span><span style="color:blue;">TABLE&nbsp;</span></strong><span style="color:olive;">`user`</span><span style="color:blue;">(</span></p><p><span style="color:olive;">`uid`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">用户名</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`xm`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">20</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">姓名</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`pwd`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">50</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">密码</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`role`&nbsp;</span><strong><span style="color:maroon;">CHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">1</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">角色</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><strong><span style="color:blue;">PRIMARY&nbsp;</span><span style="color:blue;">KEY</span></strong><span style="color:blue;">(</span><span style="color:olive;">`uid`</span><span style="color:blue;">)</span></p><p><span style="color:blue;">)</span></p><p><strong><span style="color:blue;">COMMENT</span></strong><span style="color:blue;">=</span><span style="color:green;">'</span><span style="font-family:宋体;color:green;">用户信息</span><span style="color:green;">'</span></p><p><strong><span style="color:blue;">COLLATE</span></strong><span style="color:blue;">=</span><span style="color:green;">'utf8_general_ci'</span></p><p><strong><span style="color:blue;">ENGINE</span></strong><span style="color:blue;">=</span><strong><span style="color:maroon;">InnoDB</span></strong><span style="color:blue;">;</span></p><p>&nbsp;</p><p><span style="font-family:宋体;">当管理员发布一条新闻时，就有一条新闻保存到新闻表，表结构如表</span>2-2<span style="font-family:宋体;">所示。</span></p><p><span style="font-family:黑体;">表</span>2-2 <span style="font-family:黑体;">新闻表</span>news</p><div><table border="1" cellspacing="0" cellpadding="0" width="496"> <tbody><tr><td style="width:84.35pt;"><p><strong>Field</strong></p></td><td style="width:78.3pt;"><p><strong>Type</strong></p></td><td style="width:32.1pt;"><p><strong>Null</strong></p></td><td style="width:26.35pt;"><p><strong>Key</strong></p></td><td style="width:89.85pt;"><p><strong>Default</strong></p></td><td style="width:61.4pt;"><p><strong>Comment</strong></p></td></tr><tr><td style="width:84.35pt;"><p>id</p></td><td style="width:78.3pt;"><p>int(11)</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>PRI</p></td><td style="width:89.85pt;"><p>auto_increment</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">新闻</span>id</p></td></tr><tr><td style="width:84.35pt;"><p>title</p></td><td style="width:78.3pt;"><p>varchar(255)</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>&nbsp;</p></td><td style="width:89.85pt;"><p>&nbsp;</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">新闻标题</span></p></td></tr><tr><td style="width:84.35pt;"><p>content</p></td><td style="width:78.3pt;"><p>text</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>&nbsp;</p></td><td style="width:89.85pt;"><p>&nbsp;</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">新闻内容</span></p></td></tr><tr><td style="width:84.35pt;"><p>tjdate</p></td><td style="width:78.3pt;"><p>datetime</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>&nbsp;</p></td><td style="width:89.85pt;"><p>&nbsp;</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">发布时间</span></p></td></tr><tr><td style="width:84.35pt;"><p>cruser</p></td><td style="width:78.3pt;"><p>varchar(11)</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>&nbsp;</p></td><td style="width:89.85pt;"><p>&nbsp;</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">发布者</span></p></td></tr><tr><td style="width:84.35pt;"><p>hitnum</p></td><td style="width:78.3pt;"><p>int(10)</p></td><td style="width:32.1pt;"><p>NO</p></td><td style="width:26.35pt;"><p>&nbsp;</p></td><td style="width:89.85pt;"><p>0</p></td><td style="width:61.4pt;"><p><span style="font-family:宋体;">阅读量</span></p></td></tr></tbody></table></div><p><span style="font-family:宋体;">创建</span>news<span style="font-family:宋体;">表的</span>SQL<span style="font-family:宋体;">代码如下：</span></p><p><strong><span style="color:blue;">CREATE&nbsp;</span><span style="color:blue;">TABLE&nbsp;</span></strong><span style="color:olive;">`news`</span><span style="color:blue;">(</span></p><p><span style="color:olive;">`id`&nbsp;</span><strong><span style="color:maroon;">INT</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">AUTO_INCREMENT&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">新闻</span><span style="color:green;">ID'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`title`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">100</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">DEFAULT&nbsp;</span></strong><span style="color:green;">'0'&nbsp;</span><strong><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">新闻标题</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`content`&nbsp;</span><strong><span style="color:maroon;">TEXT&nbsp;</span><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">新闻内容</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`tjdate`&nbsp;</span><strong><span style="color:maroon;">DATETIME&nbsp;</span><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">发布时间</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`cruser`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">发布者</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`hitnum`&nbsp;</span><strong><span style="color:maroon;">INT</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">DEFAULT&nbsp;</span></strong><span style="color:green;">'0'&nbsp;</span><strong><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">阅读量</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><strong><span style="color:blue;">PRIMARY&nbsp;</span><span style="color:blue;">KEY</span></strong><span style="color:blue;">(</span><span style="color:olive;">`id`</span><span style="color:blue;">)</span></p><p><span style="color:blue;">)</span></p><p><strong><span style="color:blue;">COMMENT</span></strong><span style="color:blue;">=</span><span style="color:green;">'</span><span style="font-family:宋体;color:green;">新闻</span><span style="color:green;">'</span></p><p><strong><span style="color:blue;">COLLATE</span></strong><span style="color:blue;">=</span><span style="color:green;">'utf8_general_ci'</span></p><p><strong><span style="color:blue;">ENGINE</span></strong><span style="color:blue;">=</span><strong><span style="color:maroon;">InnoDB</span></strong><span style="color:blue;">;</span></p><p>&nbsp;</p><p><span style="font-family:宋体;">管理员登录到后台时，所见的菜单栏目保存在菜单表，表结构如表</span>2-3<span style="font-family:宋体;">所示。</span></p><p><span style="font-family:黑体;">表</span>2-3 <span style="font-family:黑体;">菜单表</span>cmenu</p><div><table border="1" cellspacing="0" cellpadding="0" width="494"> <tbody><tr><td style="width:73.45pt;"><p><strong>Field</strong></p></td><td style="width:85.95pt;"><p><strong>Type</strong></p></td><td style="width:34.05pt;"><p><strong>Null</strong></p></td><td style="width:25.6pt;"><p><strong>Key</strong></p></td><td style="width:81.6pt;"><p><strong>Default</strong></p></td><td style="width:70.0pt;"><p><strong>Comment</strong></p></td></tr><tr><td style="width:73.45pt;"><p>id</p></td><td style="width:85.95pt;"><p>int</p></td><td style="width:34.05pt;"><p>NO</p></td><td style="width:25.6pt;"><p>PRI</p></td><td style="width:81.6pt;"><p>auto_increment</p></td><td style="width:70.0pt;"><p><span style="font-family:宋体;">栏目</span>id</p></td></tr><tr><td style="width:73.45pt;"><p>pid</p></td><td style="width:85.95pt;"><p>int</p></td><td style="width:34.05pt;"><p>NO</p></td><td style="width:25.6pt;"><p>&nbsp;</p></td><td style="width:81.6pt;"><p>0</p></td><td style="width:70.0pt;"><p><span style="font-family:宋体;">父级</span>id</p></td></tr><tr><td style="width:73.45pt;"><p>name</p></td><td style="width:85.95pt;"><p>varchar(50)</p></td><td style="width:34.05pt;"><p>NO</p></td><td style="width:25.6pt;"><p>&nbsp;</p></td><td style="width:81.6pt;"><p>&nbsp;</p></td><td style="width:70.0pt;"><p><span style="font-family:宋体;">栏目名称</span></p></td></tr><tr><td style="width:73.45pt;"><p>url</p></td><td style="width:85.95pt;"><p>varchar(100)</p></td><td style="width:34.05pt;"><p>YES</p></td><td style="width:25.6pt;"><p>&nbsp;</p></td><td style="width:81.6pt;"><p>&nbsp;</p></td><td style="width:70.0pt;"><p><span style="font-family:宋体;">链接</span></p></td></tr><tr><td style="width:73.45pt;"><p>permission</p></td><td style="width:85.95pt;"><p>varchar(50)</p></td><td style="width:34.05pt;"><p>YES</p></td><td style="width:25.6pt;"><p>&nbsp;</p></td><td style="width:81.6pt;"><p>&nbsp;</p></td><td style="width:70.0pt;"><p><span style="font-family:宋体;">权限标识</span></p></td></tr></tbody></table></div><p><span style="font-family:宋体;">创建</span>cmenu<span style="font-family:宋体;">表的</span>SQL<span style="font-family:宋体;">代码如下：</span></p><p><strong><span style="color:blue;">CREATE&nbsp;</span><span style="color:blue;">TABLE&nbsp;</span></strong><span style="color:olive;">`cmenu`</span><span style="color:blue;">(</span></p><p><span style="color:olive;">`id`&nbsp;</span><strong><span style="color:maroon;">INT</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">AUTO_INCREMENT&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">栏目</span><span style="color:green;">ID'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`pid`&nbsp;</span><strong><span style="color:maroon;">INT</span></strong><span style="color:blue;">(</span><span style="color:purple;">11</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">DEFAULT&nbsp;</span></strong><span style="color:green;">'0'&nbsp;</span><strong><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">父级</span><span style="color:green;">ID'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`name`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">50</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">栏目名称</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`url`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">100</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">DEFAULT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">链接</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><span style="color:olive;">`permission`&nbsp;</span><strong><span style="color:maroon;">VARCHAR</span></strong><span style="color:blue;">(</span><span style="color:purple;">50</span><span style="color:blue;">)&nbsp;</span><strong><span style="color:blue;">NOT&nbsp;</span><span style="color:blue;">NULL&nbsp;</span><span style="color:blue;">COMMENT&nbsp;</span></strong><span style="color:green;">'</span><span style="font-family:宋体;color:green;">权限标识</span><span style="color:green;">'</span><span style="color:blue;">,</span></p><p><strong><span style="color:blue;">PRIMARY&nbsp;</span><span style="color:blue;">KEY</span></strong><span style="color:blue;">(</span><span style="color:olive;">`id`</span><span style="color:blue;">)</span></p><p><span style="color:blue;">)</span></p><p><strong><span style="color:blue;">COMMENT</span></strong><span style="color:blue;">=</span><span style="color:green;">'</span><span style="font-family:宋体;color:green;">系统菜单</span><span style="color:green;">'</span></p><p><strong><span style="color:blue;">COLLATE</span></strong><span style="color:blue;">=</span><span style="color:green;">'utf8_general_ci'</span></p><p><strong><span style="color:blue;">ENGINE</span></strong><span style="color:blue;">=</span><strong><span style="color:maroon;">InnoDB</span></strong><span style="color:blue;">;</span></p><p>&nbsp;</p><br /></div>   </td>
        </tr>

		</tbody>
    </table>
<div th:include="include :: footer"></div>
</body>
</html>
